package org.moka.ioio.ioiopilot;

import org.moka.ioio.ioiopilot.gui.CommandPanel;
import org.moka.ioio.ioiopilot.gui.GraphSurface;
import org.moka.ioio.ioiopilot.input.GuiInputs;
import org.moka.ioio.ioiopilot.input.PhoneSensorInputs;
import org.moka.ioio.ioiopilot.input.RxInputs;

import android.content.Context;
import android.util.Log;

import ioio.lib.api.IOIO;
import ioio.lib.api.exception.ConnectionLostException;

public class XQuadRotorController extends AbstractController {
 
	
	public XQuadRotorController(Context context, CommandPanel commandPanel, GraphSurface graphPanel_)
			throws ConnectionLostException {
		super(context, commandPanel, graphPanel_);
		
	}

	@Override
	public void processInputToOutput()
	{
		s1.value = guiInputs.value[GuiInputs.CHANNEL_1] + (int)(0.5*phoneSensors.value[PhoneSensorInputs.ACC_X]) + phoneSensors.value[PhoneSensorInputs.GYRO_X] + rxChannels.value[RxInputs.THROTTLE]; 
		//Log.v(IOIOThread.TAG, "processInputToOutput CHANNEL_"+GuiInputs.CHANNEL_1+" progress:"+s1.value);
		s2.value = guiInputs.value[GuiInputs.CHANNEL_2];
		s3.value = guiInputs.value[GuiInputs.CHANNEL_3];
		s4.value = guiInputs.value[GuiInputs.CHANNEL_4];
		
		/*axis[PITCH]	= elevator.value; // + gyro + acc
		axis[ROLL]	= aileron.value;
		axis[YAW]	= rudder.value;
		
		s1.value = throttle.value - axis[PITCH] + axis[ROLL] - axis[YAW]; // Front L
		s2.value = throttle.value - axis[PITCH] - axis[ROLL] + axis[YAW]; // Front R
		s3.value = throttle.value + axis[PITCH] - axis[ROLL] - axis[YAW]; // Rear R
		s4.value = throttle.value + axis[PITCH] + axis[ROLL] + axis[YAW]; // Rear L
		*/
	}

}
